package com.asurplus.mail.controller;


import com.asurplus.common.layui.LayuiTableResult;
import com.asurplus.mail.service.SysEmailLogService;
import com.asurplus.mail.vo.SysEmailLogVO;
import com.asurplus.system.service.SysDictDetailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 邮件发送记录表 前端控制器
 * </p>
 *
 * @author lizhou
 * @since 2020-11-04
 */
@Controller
@RequestMapping("/mail/email-log")
public class SysEmailLogController {

    @Autowired
    private SysEmailLogService sysEmailLogService;
    @Autowired
    private SysDictDetailService dictDetailService;

    @ApiOperation(value = "请求邮件日志列表页")
    @GetMapping("init")
    public String init(Model model) {
        model.addAttribute("type", dictDetailService.listSysDictDetailByDictCode("email_type"));
        model.addAttribute("status", dictDetailService.listSysDictDetailByDictCode("email_status"));
        return "mail/emaillog/list";
    }

    @ApiOperation(value = "分页查询邮件日志数据")
    @PostMapping("list")
    @ResponseBody
    public LayuiTableResult list(Integer page, Integer limit, SysEmailLogVO sysEmailLogVO) {
        return sysEmailLogService.list(page, limit, sysEmailLogVO);
    }
}
